// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers.  See the top-level LICENSE file for dates and other
// details.  No copyright assignment is required to contribute to VisIt.

#include <PyInteractorAttributes.h>
#include <ObserverToCallback.h>
#include <stdio.h>
#include <Py2and3Support.h>

// ****************************************************************************
// Module: PyInteractorAttributes
//
// Purpose:
//   This class contains attributes associated with the main window.
//
// Note:       Autogenerated by xml2python. Do not modify by hand!
//
// Programmer: xml2python
// Creation:   omitted
//
// ****************************************************************************

//
// This struct contains the Python type information and a InteractorAttributes.
//
struct InteractorAttributesObject
{
    PyObject_HEAD
    InteractorAttributes *data;
    bool        owns;
    PyObject   *parent;
};

//
// Internal prototypes
//
static PyObject *NewInteractorAttributes(int);
std::string
PyInteractorAttributes_ToString(const InteractorAttributes *atts, const char *prefix, const bool forLogging)
{
    std::string str;
    char tmpStr[1000];

    if(atts->GetShowGuidelines())
        snprintf(tmpStr, 1000, "%sshowGuidelines = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sshowGuidelines = 0\n", prefix);
    str += tmpStr;
    if(atts->GetClampSquare())
        snprintf(tmpStr, 1000, "%sclampSquare = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sclampSquare = 0\n", prefix);
    str += tmpStr;
    if(atts->GetFillViewportOnZoom())
        snprintf(tmpStr, 1000, "%sfillViewportOnZoom = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%sfillViewportOnZoom = 0\n", prefix);
    str += tmpStr;
    const char *navigationMode_names = "Trackball, Dolly, Flythrough";
    switch (atts->GetNavigationMode())
    {
      case InteractorAttributes::Trackball:
          snprintf(tmpStr, 1000, "%snavigationMode = %sTrackball  # %s\n", prefix, prefix, navigationMode_names);
          str += tmpStr;
          break;
      case InteractorAttributes::Dolly:
          snprintf(tmpStr, 1000, "%snavigationMode = %sDolly  # %s\n", prefix, prefix, navigationMode_names);
          str += tmpStr;
          break;
      case InteractorAttributes::Flythrough:
          snprintf(tmpStr, 1000, "%snavigationMode = %sFlythrough  # %s\n", prefix, prefix, navigationMode_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    if(atts->GetAxisArraySnap())
        snprintf(tmpStr, 1000, "%saxisArraySnap = 1\n", prefix);
    else
        snprintf(tmpStr, 1000, "%saxisArraySnap = 0\n", prefix);
    str += tmpStr;
    const char *boundingBoxMode_names = "Always, Never, Auto";
    switch (atts->GetBoundingBoxMode())
    {
      case InteractorAttributes::Always:
          snprintf(tmpStr, 1000, "%sboundingBoxMode = %sAlways  # %s\n", prefix, prefix, boundingBoxMode_names);
          str += tmpStr;
          break;
      case InteractorAttributes::Never:
          snprintf(tmpStr, 1000, "%sboundingBoxMode = %sNever  # %s\n", prefix, prefix, boundingBoxMode_names);
          str += tmpStr;
          break;
      case InteractorAttributes::Auto:
          snprintf(tmpStr, 1000, "%sboundingBoxMode = %sAuto  # %s\n", prefix, prefix, boundingBoxMode_names);
          str += tmpStr;
          break;
      default:
          break;
    }

    return str;
}

static PyObject *
InteractorAttributes_Notify(PyObject *self, PyObject *args)
{
    InteractorAttributesObject *obj = (InteractorAttributesObject *)self;
    obj->data->Notify();
    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
InteractorAttributes_SetShowGuidelines(PyObject *self, PyObject *args)
{
    InteractorAttributesObject *obj = (InteractorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the showGuidelines in the object.
    obj->data->SetShowGuidelines(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
InteractorAttributes_GetShowGuidelines(PyObject *self, PyObject *args)
{
    InteractorAttributesObject *obj = (InteractorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetShowGuidelines()?1L:0L);
    return retval;
}

/*static*/ PyObject *
InteractorAttributes_SetClampSquare(PyObject *self, PyObject *args)
{
    InteractorAttributesObject *obj = (InteractorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the clampSquare in the object.
    obj->data->SetClampSquare(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
InteractorAttributes_GetClampSquare(PyObject *self, PyObject *args)
{
    InteractorAttributesObject *obj = (InteractorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetClampSquare()?1L:0L);
    return retval;
}

/*static*/ PyObject *
InteractorAttributes_SetFillViewportOnZoom(PyObject *self, PyObject *args)
{
    InteractorAttributesObject *obj = (InteractorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the fillViewportOnZoom in the object.
    obj->data->SetFillViewportOnZoom(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
InteractorAttributes_GetFillViewportOnZoom(PyObject *self, PyObject *args)
{
    InteractorAttributesObject *obj = (InteractorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetFillViewportOnZoom()?1L:0L);
    return retval;
}

/*static*/ PyObject *
InteractorAttributes_SetNavigationMode(PyObject *self, PyObject *args)
{
    InteractorAttributesObject *obj = (InteractorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 3)
    {
        std::stringstream ss;
        ss << "An invalid navigationMode value was given." << std::endl;
        ss << "Valid values are in the range [0,2]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " Trackball";
        ss << ", Dolly";
        ss << ", Flythrough";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the navigationMode in the object.
    obj->data->SetNavigationMode(InteractorAttributes::NavigationMode(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
InteractorAttributes_GetNavigationMode(PyObject *self, PyObject *args)
{
    InteractorAttributesObject *obj = (InteractorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetNavigationMode()));
    return retval;
}

/*static*/ PyObject *
InteractorAttributes_SetAxisArraySnap(PyObject *self, PyObject *args)
{
    InteractorAttributesObject *obj = (InteractorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    bool cval = bool(val);

    if (val == -1 && PyErr_Occurred())
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ bool");
    }
    if (fabs(double(val))>1.5E-7 && fabs((double(long(cval))-double(val))/double(val))>1.5E-7)
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_ValueError, "arg not interpretable as C++ bool");
    }

    Py_XDECREF(packaged_args);

    // Set the axisArraySnap in the object.
    obj->data->SetAxisArraySnap(cval);

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
InteractorAttributes_GetAxisArraySnap(PyObject *self, PyObject *args)
{
    InteractorAttributesObject *obj = (InteractorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(obj->data->GetAxisArraySnap()?1L:0L);
    return retval;
}

/*static*/ PyObject *
InteractorAttributes_SetBoundingBoxMode(PyObject *self, PyObject *args)
{
    InteractorAttributesObject *obj = (InteractorAttributesObject *)self;

    PyObject *packaged_args = 0;

    // Handle args packaged into a tuple of size one
    // if we think the unpackaged args matches our needs
    if (PySequence_Check(args) && PySequence_Size(args) == 1)
    {
        packaged_args = PySequence_GetItem(args, 0);
        if (PyNumber_Check(packaged_args))
            args = packaged_args;
    }

    if (PySequence_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "expecting a single number arg");
    }

    if (!PyNumber_Check(args))
    {
        Py_XDECREF(packaged_args);
        return PyErr_Format(PyExc_TypeError, "arg is not a number type");
    }

    long val = PyLong_AsLong(args);
    int cval = int(val);

    if ((val == -1 && PyErr_Occurred()) || long(cval) != val)
    {
        Py_XDECREF(packaged_args);
        PyErr_Clear();
        return PyErr_Format(PyExc_TypeError, "arg not interpretable as C++ int");
    }

    if (cval < 0 || cval >= 3)
    {
        std::stringstream ss;
        ss << "An invalid boundingBoxMode value was given." << std::endl;
        ss << "Valid values are in the range [0,2]." << std::endl;
        ss << "You can also use the following symbolic names:";
        ss << " Always";
        ss << ", Never";
        ss << ", Auto";
        return PyErr_Format(PyExc_ValueError, ss.str().c_str());
    }

    Py_XDECREF(packaged_args);

    // Set the boundingBoxMode in the object.
    obj->data->SetBoundingBoxMode(InteractorAttributes::BoundingBoxMode(cval));

    Py_INCREF(Py_None);
    return Py_None;
}

/*static*/ PyObject *
InteractorAttributes_GetBoundingBoxMode(PyObject *self, PyObject *args)
{
    InteractorAttributesObject *obj = (InteractorAttributesObject *)self;
    PyObject *retval = PyInt_FromLong(long(obj->data->GetBoundingBoxMode()));
    return retval;
}



PyMethodDef PyInteractorAttributes_methods[INTERACTORATTRIBUTES_NMETH] = {
    {"Notify", InteractorAttributes_Notify, METH_VARARGS},
    {"SetShowGuidelines", InteractorAttributes_SetShowGuidelines, METH_VARARGS},
    {"GetShowGuidelines", InteractorAttributes_GetShowGuidelines, METH_VARARGS},
    {"SetClampSquare", InteractorAttributes_SetClampSquare, METH_VARARGS},
    {"GetClampSquare", InteractorAttributes_GetClampSquare, METH_VARARGS},
    {"SetFillViewportOnZoom", InteractorAttributes_SetFillViewportOnZoom, METH_VARARGS},
    {"GetFillViewportOnZoom", InteractorAttributes_GetFillViewportOnZoom, METH_VARARGS},
    {"SetNavigationMode", InteractorAttributes_SetNavigationMode, METH_VARARGS},
    {"GetNavigationMode", InteractorAttributes_GetNavigationMode, METH_VARARGS},
    {"SetAxisArraySnap", InteractorAttributes_SetAxisArraySnap, METH_VARARGS},
    {"GetAxisArraySnap", InteractorAttributes_GetAxisArraySnap, METH_VARARGS},
    {"SetBoundingBoxMode", InteractorAttributes_SetBoundingBoxMode, METH_VARARGS},
    {"GetBoundingBoxMode", InteractorAttributes_GetBoundingBoxMode, METH_VARARGS},
    {NULL, NULL}
};

//
// Type functions
//

static void
InteractorAttributes_dealloc(PyObject *v)
{
   InteractorAttributesObject *obj = (InteractorAttributesObject *)v;
   if(obj->parent != 0)
       Py_DECREF(obj->parent);
   if(obj->owns)
       delete obj->data;
}

static PyObject *InteractorAttributes_richcompare(PyObject *self, PyObject *other, int op);
PyObject *
PyInteractorAttributes_getattr(PyObject *self, char *name)
{
    if(strcmp(name, "showGuidelines") == 0)
        return InteractorAttributes_GetShowGuidelines(self, NULL);
    if(strcmp(name, "clampSquare") == 0)
        return InteractorAttributes_GetClampSquare(self, NULL);
    if(strcmp(name, "fillViewportOnZoom") == 0)
        return InteractorAttributes_GetFillViewportOnZoom(self, NULL);
    if(strcmp(name, "navigationMode") == 0)
        return InteractorAttributes_GetNavigationMode(self, NULL);
    if(strcmp(name, "Trackball") == 0)
        return PyInt_FromLong(long(InteractorAttributes::Trackball));
    if(strcmp(name, "Dolly") == 0)
        return PyInt_FromLong(long(InteractorAttributes::Dolly));
    if(strcmp(name, "Flythrough") == 0)
        return PyInt_FromLong(long(InteractorAttributes::Flythrough));

    if(strcmp(name, "axisArraySnap") == 0)
        return InteractorAttributes_GetAxisArraySnap(self, NULL);
    if(strcmp(name, "boundingBoxMode") == 0)
        return InteractorAttributes_GetBoundingBoxMode(self, NULL);
    if(strcmp(name, "Always") == 0)
        return PyInt_FromLong(long(InteractorAttributes::Always));
    if(strcmp(name, "Never") == 0)
        return PyInt_FromLong(long(InteractorAttributes::Never));
    if(strcmp(name, "Auto") == 0)
        return PyInt_FromLong(long(InteractorAttributes::Auto));



    // Add a __dict__ answer so that dir() works
    if (!strcmp(name, "__dict__"))
    {
        PyObject *result = PyDict_New();
        for (int i = 0; PyInteractorAttributes_methods[i].ml_meth; i++)
            PyDict_SetItem(result,
                PyString_FromString(PyInteractorAttributes_methods[i].ml_name),
                PyString_FromString(PyInteractorAttributes_methods[i].ml_name));
        return result;
    }

    return Py_FindMethod(PyInteractorAttributes_methods, self, name);
}

int
PyInteractorAttributes_setattr(PyObject *self, char *name, PyObject *args)
{
    PyObject NULL_PY_OBJ;
    PyObject *obj = &NULL_PY_OBJ;

    if(strcmp(name, "showGuidelines") == 0)
        obj = InteractorAttributes_SetShowGuidelines(self, args);
    else if(strcmp(name, "clampSquare") == 0)
        obj = InteractorAttributes_SetClampSquare(self, args);
    else if(strcmp(name, "fillViewportOnZoom") == 0)
        obj = InteractorAttributes_SetFillViewportOnZoom(self, args);
    else if(strcmp(name, "navigationMode") == 0)
        obj = InteractorAttributes_SetNavigationMode(self, args);
    else if(strcmp(name, "axisArraySnap") == 0)
        obj = InteractorAttributes_SetAxisArraySnap(self, args);
    else if(strcmp(name, "boundingBoxMode") == 0)
        obj = InteractorAttributes_SetBoundingBoxMode(self, args);

    if (obj != NULL && obj != &NULL_PY_OBJ)
        Py_DECREF(obj);

    if (obj == &NULL_PY_OBJ)
    {
        obj = NULL;
        PyErr_Format(PyExc_NameError, "name '%s' is not defined", name);
    }
    else if (obj == NULL && !PyErr_Occurred())
        PyErr_Format(PyExc_RuntimeError, "unknown problem with '%s'", name);

    return (obj != NULL) ? 0 : -1;
}

static int
InteractorAttributes_print(PyObject *v, FILE *fp, int flags)
{
    InteractorAttributesObject *obj = (InteractorAttributesObject *)v;
    fprintf(fp, "%s", PyInteractorAttributes_ToString(obj->data, "",false).c_str());
    return 0;
}

PyObject *
InteractorAttributes_str(PyObject *v)
{
    InteractorAttributesObject *obj = (InteractorAttributesObject *)v;
    return PyString_FromString(PyInteractorAttributes_ToString(obj->data,"", false).c_str());
}

//
// The doc string for the class.
//
#if PY_MAJOR_VERSION > 2 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION >= 5)
static const char *InteractorAttributes_Purpose = "This class contains attributes associated with the main window.";
#else
static char *InteractorAttributes_Purpose = "This class contains attributes associated with the main window.";
#endif

//
// Python Type Struct Def Macro from Py2and3Support.h
//
//         VISIT_PY_TYPE_OBJ( VPY_TYPE,
//                            VPY_NAME,
//                            VPY_OBJECT,
//                            VPY_DEALLOC,
//                            VPY_PRINT,
//                            VPY_GETATTR,
//                            VPY_SETATTR,
//                            VPY_STR,
//                            VPY_PURPOSE,
//                            VPY_RICHCOMP,
//                            VPY_AS_NUMBER)

//
// The type description structure
//

VISIT_PY_TYPE_OBJ(InteractorAttributesType,         \
                  "InteractorAttributes",           \
                  InteractorAttributesObject,       \
                  InteractorAttributes_dealloc,     \
                  InteractorAttributes_print,       \
                  PyInteractorAttributes_getattr,   \
                  PyInteractorAttributes_setattr,   \
                  InteractorAttributes_str,         \
                  InteractorAttributes_Purpose,     \
                  InteractorAttributes_richcompare, \
                  0); /* as_number*/

//
// Helper function for comparing.
//
static PyObject *
InteractorAttributes_richcompare(PyObject *self, PyObject *other, int op)
{
    // only compare against the same type 
    if ( Py_TYPE(self) != &InteractorAttributesType
         || Py_TYPE(other) != &InteractorAttributesType)
    {
        Py_INCREF(Py_NotImplemented);
        return Py_NotImplemented;
    }

    PyObject *res = NULL;
    InteractorAttributes *a = ((InteractorAttributesObject *)self)->data;
    InteractorAttributes *b = ((InteractorAttributesObject *)other)->data;

    switch (op)
    {
       case Py_EQ:
           res = (*a == *b) ? Py_True : Py_False;
           break;
       case Py_NE:
           res = (*a != *b) ? Py_True : Py_False;
           break;
       default:
           res = Py_NotImplemented;
           break;
    }

    Py_INCREF(res);
    return res;
}

//
// Helper functions for object allocation.
//

static InteractorAttributes *defaultAtts = 0;
static InteractorAttributes *currentAtts = 0;

static PyObject *
NewInteractorAttributes(int useCurrent)
{
    InteractorAttributesObject *newObject;
    newObject = PyObject_NEW(InteractorAttributesObject, &InteractorAttributesType);
    if(newObject == NULL)
        return NULL;
    if(useCurrent && currentAtts != 0)
        newObject->data = new InteractorAttributes(*currentAtts);
    else if(defaultAtts != 0)
        newObject->data = new InteractorAttributes(*defaultAtts);
    else
        newObject->data = new InteractorAttributes;
    newObject->owns = true;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

static PyObject *
WrapInteractorAttributes(const InteractorAttributes *attr)
{
    InteractorAttributesObject *newObject;
    newObject = PyObject_NEW(InteractorAttributesObject, &InteractorAttributesType);
    if(newObject == NULL)
        return NULL;
    newObject->data = (InteractorAttributes *)attr;
    newObject->owns = false;
    newObject->parent = 0;
    return (PyObject *)newObject;
}

///////////////////////////////////////////////////////////////////////////////
//
// Interface that is exposed to the VisIt module.
//
///////////////////////////////////////////////////////////////////////////////

PyObject *
InteractorAttributes_new(PyObject *self, PyObject *args)
{
    int useCurrent = 0;
    if (!PyArg_ParseTuple(args, "i", &useCurrent))
    {
        if (!PyArg_ParseTuple(args, ""))
            return NULL;
        else
            PyErr_Clear();
    }

    return (PyObject *)NewInteractorAttributes(useCurrent);
}

//
// Plugin method table. These methods are added to the visitmodule's methods.
//
static PyMethodDef InteractorAttributesMethods[] = {
    {"InteractorAttributes", InteractorAttributes_new, METH_VARARGS},
    {NULL,      NULL}        /* Sentinel */
};

static Observer *InteractorAttributesObserver = 0;

std::string
PyInteractorAttributes_GetLogString()
{
    std::string s("InteractorAtts = InteractorAttributes()\n");
    if(currentAtts != 0)
        s += PyInteractorAttributes_ToString(currentAtts, "InteractorAtts.", true);
    return s;
}

static void
PyInteractorAttributes_CallLogRoutine(Subject *subj, void *data)
{
    typedef void (*logCallback)(const std::string &);
    logCallback cb = (logCallback)data;

    if(cb != 0)
    {
        std::string s("InteractorAtts = InteractorAttributes()\n");
        s += PyInteractorAttributes_ToString(currentAtts, "InteractorAtts.", true);
        cb(s);
    }
}

void
PyInteractorAttributes_StartUp(InteractorAttributes *subj, void *data)
{
    if(subj == 0)
        return;

    currentAtts = subj;
    PyInteractorAttributes_SetDefaults(subj);

    //
    // Create the observer that will be notified when the attributes change.
    //
    if(InteractorAttributesObserver == 0)
    {
        InteractorAttributesObserver = new ObserverToCallback(subj,
            PyInteractorAttributes_CallLogRoutine, (void *)data);
    }

}

void
PyInteractorAttributes_CloseDown()
{
    delete defaultAtts;
    defaultAtts = 0;
    delete InteractorAttributesObserver;
    InteractorAttributesObserver = 0;
}

PyMethodDef *
PyInteractorAttributes_GetMethodTable(int *nMethods)
{
    *nMethods = 1;
    return InteractorAttributesMethods;
}

bool
PyInteractorAttributes_Check(PyObject *obj)
{
    return (obj->ob_type == &InteractorAttributesType);
}

InteractorAttributes *
PyInteractorAttributes_FromPyObject(PyObject *obj)
{
    InteractorAttributesObject *obj2 = (InteractorAttributesObject *)obj;
    return obj2->data;
}

PyObject *
PyInteractorAttributes_New()
{
    return NewInteractorAttributes(0);
}

PyObject *
PyInteractorAttributes_Wrap(const InteractorAttributes *attr)
{
    return WrapInteractorAttributes(attr);
}

void
PyInteractorAttributes_SetParent(PyObject *obj, PyObject *parent)
{
    InteractorAttributesObject *obj2 = (InteractorAttributesObject *)obj;
    obj2->parent = parent;
}

void
PyInteractorAttributes_SetDefaults(const InteractorAttributes *atts)
{
    if(defaultAtts)
        delete defaultAtts;

    defaultAtts = new InteractorAttributes(*atts);
}

